#include "LoginWindow.h"
#include "Splash.h"
#include <QApplication>
#include <QtPlugin>
#include <QSplashScreen>
#include <QPixmap>
#include <QTimer>

QSqlDatabase enjoylifedb;

extern QString host;

/**
 * @brief main
 * @param argc
 * @param argv
 * @return
 */
int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    //Load drivers for deploy the app
    a.addLibraryPath(a.applicationDirPath() + "/sqldrivers");

    Splash *sp = new Splash();
    sp->show();

    LoginWindow w;
    w.LeerArchivoConf();

    enjoylifedb = QSqlDatabase::addDatabase("QPSQL");
    enjoylifedb.setHostName(host);
    enjoylifedb.setPort(5432);
    enjoylifedb.setDatabaseName("enjoylifedb");

    QTimer::singleShot(2500,sp,SLOT(close()));
    QTimer::singleShot(2500,&w,SLOT(show())); // Se muestra la login window cuando se cierra el splash

    return a.exec();
}
